package com.mcy.springbatch.reader;

import com.mcy.springbatch.entity.SysUser;
import com.mcy.springbatch.util.IDCardNoUtil;
import com.mcy.springbatch.util.RandomValueUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.configuration.annotation.JobScope;
import org.springframework.batch.item.support.ListItemReader;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : Create By mcy
 * @date : 2019/8/25 22:36:34
 */
@Slf4j
@Configuration
public class ReadUserDataListItemReader{

    @Bean
    public ListItemReader<SysUser> userDataListItemReader(){
        List<SysUser> list = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            String sex = i % 3 == 0 ? "男" : "女";
            list.add(new SysUser(i + 1, RandomValueUtil.getRandomString(16), RandomValueUtil.getChineseName(), IDCardNoUtil.getIdNo(sex.equals("男")), RandomValueUtil.getTel()
                    , sex, RandomValueUtil.getRoad(), RandomValueUtil.getEmail(6, 16), 1));
        }
        return new ListItemReader<>(list);
    }



}
